﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using log4net;
using DWH.PP;
using System.Threading;

namespace RDService
{
    static class RDServicePortal
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        /// 

        private static ILog logger;

        static void Main(string[] args)
        {
            //logger = LogManager.GetLogger(typeof(RDServicePortal));

            //logger.InfoFormat("service start at:{0}", DateTime.Now.ToString());

            if (args == null || args.Length == 0)
            {
                ServiceBase[] ServicesToRun;
                ServicesToRun = new ServiceBase[] 
			    { 
				    new RDService() 
			    };
                ServiceBase.Run(ServicesToRun);
            }
            else
            {
                PPTaskExecutor exe = new PPTaskExecutor();
                exe.RDConfigFile = args[0];

                exe.InitializeTasks();
                exe.StartTasks();

                //logger.InfoFormat("PPTaskExecutor is running, will wait for 2 hours to exit");
                //Console.ReadKey();
                Thread.Sleep(2 * 60 * 60 * 1000);
            }
        }
    }
}
